﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JigLibX.Physics;
using JigLibX.Geometry;
using JigLibX.Math;
using JigLibX.Utils;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace RPG
{
    public class CGameChaseCamera : CGameCamera
    {
        protected CGameEntity m_ChaseEntity;
        protected Vector3 m_Offset = new Vector3(0, 8, -16);

        public CGameEntity ChaseEntity
        {
            get
            {
                return m_ChaseEntity;
            }
            set
            {
                m_ChaseEntity = value;
            }
        }

        public Vector3 Offset
        {
            get
            {
                return m_Offset;
            }
            set
            {
                m_Offset = value;
            }
        }

        public CGameChaseCamera(GraphicsDeviceManager graphics, CGameEntity _chase) : base(graphics)
        {
            m_ChaseEntity = _chase;
        }

        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            Quaternion q = m_ChaseEntity.Rotation;
            m_Position = Vector3.Transform(m_Offset, Matrix.CreateFromQuaternion(q));
            m_Position = m_Position + m_ChaseEntity.Position;
            m_TargetPos = m_ChaseEntity.Position;
            CalcViewMatrix();
        }
    }
}
